package com.financial.business.balance.service.impl;

import com.financial.business.balance.constants.FinancialPayBalanceEnumConstants;
import com.financial.business.balance.service.FinancialBalancePayService;
import com.financial.business.balance.service.gy.FinancialGYBalancePayService;
import com.financial.business.balance.utils.JsonUtils;
import com.financial.business.balance.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author WANGNING
 * @Email wyn20140226@aliyun.com
 * @Description //余额支付业务处理
 * @Date 2019/12/4 10:28
 */
@Service
public class FinancialBalancePayServiceImpl implements FinancialBalancePayService {
    public static final Logger logger = LoggerFactory.getLogger(FinancialBalancePayServiceImpl.class);
    @Autowired
    private FinancialGYBalancePayService financialGYBalancePayService;

    @Override
    public ApiResult pay(String requestParam) {
        logger.info("FinancialBalancePayServiceImpl.pay()-----余额支付获取到的json信息为：" + requestParam);
        /*解析参数信息判断支付渠道*/
        Map<String, Object> map = JsonUtils.jsonToMap(requestParam);
        String payChannelNo = (String) map.get("pay_channel_no");
        logger.info("FinancialBalancePayServiceImpl.pay()-----余额支付支付渠道为：" + payChannelNo);
        ApiResult apiResult = ApiResult.failure(FinancialPayBalanceEnumConstants.ENUM_RETURNMESSAGE_FAIL);
        /*判断支付渠道*/
        if (payChannelNo.equalsIgnoreCase(FinancialPayBalanceEnumConstants.ENUM_PAYCHANNEL_GYBALANCE)) {
            /*够样平台余额支付*/
            apiResult = financialGYBalancePayService.pay(requestParam);
        }
        return apiResult;
    }
}
